package com.boot.controller.user;

import com.alibaba.fastjson.JSON;
import com.boot.common.message.AjaxResult;
import com.boot.common.message.BaseService;
import com.boot.common.message.RequestPageHead;
import com.boot.common.message.ResultPage;
import com.boot.entity.user.UserEntity;
import com.boot.service.user.IUserService;
import com.boot.service.user.IUserServiceRedis;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author Cheng JiYe
 * @description:
 * @date 2020/10/3 20:28
 */
@Api(tags = "用户表接口(测试redis)")
@RestController
@RequestMapping("/user/redis/")
@Slf4j
public class UserRedisController {
    @Autowired
    private IUserServiceRedis userServiceRedis;

    @ApiOperation(value = "获取用户表列表")
    @PostMapping("list")
    public ResultPage<List<UserEntity>> list(@RequestBody RequestPageHead req) {
        log.debug("UserRedisController::list接口开始执行... " + "参数是：" + JSON.toJSONString(req));
        return BaseService.packPageResult(userServiceRedis.queryUserEntityList(req));

    }

    @ApiOperation(value = "按userId获取用户表详情")
    @PostMapping("detail")
    public AjaxResult<UserEntity> detail(@RequestBody UserEntity reqDetail) {
        log.debug("UserRedisController::detail接口开始执行... " + "参数是：" + JSON.toJSONString(reqDetail));
        return AjaxResult.success(userServiceRedis.queryUserEntityById(reqDetail));
    }

}
